#include "AccountHandler.h"
#include "boost/bind.hpp"
#include "DispatchHandler.h"

#include "RPC_dispatch.pb.h"

void AccountRpcHandler::init()
{
	regRpcHandler("requestHandle", boost::bind(&AccountRpcHandler::remote_dispatch, this, _1));
}

google::protobuf::Message* AccountRpcHandler::remote_dispatch(const string& params)
{
	FUNCTIONLOG

	RPC_RequestHandle proto;
	__TRY__
		proto.ParseFromString(params);

		Dispatcher.execMessageHandler(proto.msg_id(), proto.net_id(), &proto);

	__CATCH_STD_EXCEPT_ERROR__

		LOGE("Parse protobuf error ==> [ %s ]", e.what());

	__TRY_END__

	return nullptr;
}
